myTeamController = BaseController.extend({
	template:'myTeam',
	center:'我的团队',
	mainView: 'myTeam',
	goodsListData:new ReactiveVar([]),
	waitOn:function(){
		var id= this.params.query.id;
		var level_name = this.params.query.level_name;
		let self = this;

		if (level_name == 'monitor' && id){
			Meteor.subscribe('classCodes',{partner_id: parseInt(id)}, {});
		}else if ((level_name == 'company' || level_name == 'platoon') && id){
				if(typeof(id) != 'undefined'){
					this.get('common/get-plg',{partner_id:id,level_name: level_name}).then(function(res){
						var arr = [];
						var data = res.data;
						for(var i in data){
							arr.push(data[i])
						}
						self.goodsListData.set(arr);
					},function(err){
						console.log(err)
					})
				}
		}
	},
	onRendered:function(){
		var myApp = new Framework7({
			modalTitle: "提示",
			modalButtonOk: "确定",
			modalButtonCancel: "取消",
		});
		var $$ = Dom7;
	},
	events: function(){
		return {
			'click .x7-partnerHome-select': function(e){
				var id = e.currentTarget.id;
				if ($("#id_"+id).css('display') == 'none'){					
					$("#id_"+id).css("display", "block");
				}else {	
					$("#id_"+id).css("display", "none");
				}
			}
		};
	},
	data: function() {
		let self = this;
		var level_name = self.params.query.level_name;
		console.log('level_name:'+level_name);
		return {
			my_team: function(){
				switch(level_name){
					case "company":
					case "platoon":
						return self.goodsListData.get();
						break;
					case "monitor":
						return ClassCodes.find().fetch();
						break;
					default:
						//return {};
				}
			},
			isMonitor: function(){
				if (level_name == 'monitor')
					return true;
				return false;
			},
		};
	}
})